import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
import commonRoutes from "@/router/routes";

import "nprogress/nprogress.css"; // 进度条样式

import { App } from "vue";
import { createRouterGuards } from "./router-guards";

export const routes: Array<any> = [
  {
    path: "/",
    name: "Layout",
    component: () => import("@/components/layout/index.vue"),
    redirect: "/home",
    children: commonRoutes,
  },
  {
    path: "/register",
    name: "Register",
    component: () => import("@/pages/register.vue"),
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("@/pages/login.vue"),
  },
];

const router = createRouter({
  history: createWebHashHistory(""),
  routes,
});

export function setupRouter(app: App) {
  // 创建路由守卫
  createRouterGuards(router);
  app.use(router);
  
}
export default router;
